<?php 
if (!isset($instance['category'])){
	$instance['category'] = 0;
}
extract($instance);

$default = array(
	'category' => $category,
	'orderby' => $orderby,
	'order' => $order,
	'include' => $include,
	'exclude' => $exclude,
	'post_status' => 'publish',
	'numberposts' => $numberposts
);

$list = get_posts($default);
//var_dump($list);
if (count($list)>0){
?>
<div class="widget-post-format">
	<div class="widget-pformat-content clearfix">
		<?php 
		foreach ($list as $post){
			
			if (has_post_format('video', $post)) {
				$icon = 'icon-facetime-video';
			}
			elseif (has_post_format('aside', $post)) {
				$icon = 'icon-edit';
			}
			elseif (has_post_format('audio', $post)) {
				$icon = 'icon-volume-down';
			}
			elseif (has_post_format('quote', $post)) {
				$icon = 'icon-quote-left';
			}
			elseif (has_post_format('status', $post)) {
				$icon = 'icon-comment';
			}
			elseif (has_post_format('chat', $post)) {
				$icon = 'icon-comments';
			}
			elseif (has_post_format(array('image', 'gallery'), $post)) {
				$icon = 'icon-picture';
			
						
			}else $icon = 'icon-pencil';
		?>
<?php $author = get_userdata($post->post_author)?>
		<div class="widget-pformat-detail">
			<div class="widget-post">
				<div class="widget-title">
					<h4><a href="<?php echo post_permalink($post->ID)?>"><?php echo $post->post_title;?></a></h4>
					<ul class="list-inline">
						<li> 
							<i class="icon-calendar-empty"></i>
							<?php echo human_time_diff(strtotime($post->post_date), current_time('timestamp') ) . ' ago'; ?>
						</li>
						<li class="user-post">
							<i class="icon-user"></i>
							<a href="<?php echo get_author_posts_url($post->post_author);?>"><?php echo $author->data->user_login; ?></a>
						
						</li>
					</ul>
					
				</div>
				
				<div class="widget-thumb second-effect">
					<div class="icon-image-top"><i <?php echo 'class="'.$icon.'"'; ?>></i></div>
					<div class="img_over">
						<?php echo get_the_post_thumbnail($post->ID, 'thumbnail'); ?>
					</div>
				</div>
				<div class="widget-caption">
					<?php 
					if ( preg_match('/<!--more(.*?)?-->/', $post->post_content, $matches) ) {
						$content = explode($matches[0], $post->post_content, 2);
						$content = $content[0];
					} else {
						$content = self::ya_trim_words($post->post_content, $length, ' ');
					}
					echo $content;
					?>
				</div>
				<div class="widget-read-more">
					<a  href="<?php echo post_permalink($post->ID)?>">
						<i class="icon-circle-arrow-right"></i><?php _e('More Details', 'yatheme'); ?>
					</a>
				</div>
			</div>
		</div>
		<?php }?>
	</div>
</div>
<?php }

?>